package com.qishi.exampleOne.jdkProxy;

import com.qishi.exampleOne.ForumService;

import java.lang.reflect.Proxy;

public class TestForumService2 {

    public static void main(String[] args) {

        //希望被代理的目标类
        ForumServiceImpl2 target = new ForumServiceImpl2();

        //将目标代码和横切代码编织到一起
        PerformaceHandler handler = new PerformaceHandler(target);

        //根据编织了目标业务类逻辑和性能监测横切逻辑的InvocationHandler 实例创建代理实例
        ForumService proxy = (ForumService)Proxy.newProxyInstance(target.getClass().getClassLoader(),target.getClass().getInterfaces(),handler);

        proxy.removeForum(10);
        proxy.removeTopic(1012);
    }
}
